#include "QtStra_Userdata.h"


QtStraUserdata::QtStraUserdata(int straindex)
{
	m_straindex = straindex;



	m_pstra1userdata = NULL;
	m_pstra2userdata = NULL;
	m_pstra3userdata = NULL;


	if (1 == m_straindex)
	{
		m_pstra1userdata = new QtStraUserdataCore<userdata_stra1>();
	}	
	else if (2 == m_straindex)
	{
		m_pstra2userdata = new QtStraUserdataCore<userdata_stra2>();
	}		
	else if (3 == m_straindex)
	{
		m_pstra3userdata = new QtStraUserdataCore<userdata_stra3>();
	}


}


//
//
//void QtStraUserdata::SetOld(char* data)
//{
//	if (1 == m_straindex)
//	{
//		m_pstra1userdata->SetOld(*((vector<QtStraUserdataCore<userdata_stra1>::QtStraData>*) data));
//	}	
//	else if (2 == m_straindex)
//	{
//		m_pstra2userdata->SetOld(*((vector<QtStraUserdataCore<userdata_stra2>::QtStraData>*) data));
//	}		
//	else if (3 == m_straindex)
//	{
//		m_pstra3userdata->SetOld(*((vector<QtStraUserdataCore<userdata_stra3>::QtStraData>*) data));
//	}
//
//}
//
//char* QtStraUserdata::GetOld()
//{
//	if (1 == m_straindex)
//	{
//		return (char*) (&m_pstra1userdata->GetOld());
//	}	
//	else if (2 == m_straindex)
//	{
//		return (char*) (&m_pstra2userdata->GetOld());
//	}		
//	else if (3 == m_straindex)
//	{
//		return (char*) (&m_pstra3userdata->GetOld());
//	}
//}
//
//void QtStraUserdata::SetNew(char* data)
//{
//	if (1 == m_straindex)
//	{
//		m_pstra1userdata->SetNew(*((vector<QtStraUserdataCore<userdata_stra1>::QtStraData>*) data));
//	}	
//	else if (2 == m_straindex)
//	{
//		m_pstra2userdata->SetNew(*((vector<QtStraUserdataCore<userdata_stra2>::QtStraData>*) data));
//	}		
//	else if (3 == m_straindex)
//	{
//		m_pstra3userdata->SetNew(*((vector<QtStraUserdataCore<userdata_stra3>::QtStraData>*) data));
//	}
//}
//
//
//
//char* QtStraUserdata::GetNew()
//{
//	if (1 == m_straindex)
//	{
//		return (char*) (&m_pstra1userdata->GetNew());
//	}	
//	else if (2 == m_straindex)
//	{
//		return (char*) (&m_pstra2userdata->GetNew());
//	}		
//	else if (3 == m_straindex)
//	{
//		return (char*) (&m_pstra3userdata->GetNew());
//	}
//}

void QtStraUserdata::AddNew(QtStraUserdataCore<userdata_stra1>::QtStraData& data)
{
	m_pstra1userdata->AddNew(data);
}

void QtStraUserdata::AddNew(QtStraUserdataCore<userdata_stra2>::QtStraData& data)
{
	m_pstra2userdata->AddNew(data);
}

void QtStraUserdata::AddNew(QtStraUserdataCore<userdata_stra3>::QtStraData& data)
{
	m_pstra3userdata->AddNew(data);
}


void QtStraUserdata::SwapOldAndNew()
{
	if (1 == m_straindex)
	{
		
		vector<QtStraUserdataCore<userdata_stra1>::QtStraData> tmp = m_pstra1userdata->GetNew();

		m_pstra1userdata->SetNew(m_pstra1userdata->GetOld());

		m_pstra1userdata->SetOld(tmp);


	}	
	else if (2 == m_straindex)
	{
		vector<QtStraUserdataCore<userdata_stra2>::QtStraData> tmp = m_pstra2userdata->GetNew();

		m_pstra2userdata->SetNew(m_pstra2userdata->GetOld());

		m_pstra2userdata->SetOld(tmp);
	}		
	else if (3 == m_straindex)
	{
		vector<QtStraUserdataCore<userdata_stra3>::QtStraData> tmp = m_pstra3userdata->GetNew();

		m_pstra3userdata->SetNew(m_pstra3userdata->GetOld());

		m_pstra3userdata->SetOld(tmp);
	}
}


void QtStraUserdata::SetOldFromNew()
{

	if (1 == m_straindex)
	{
		m_pstra1userdata->SetOld(m_pstra1userdata->GetNew());

	}	
	else if (2 == m_straindex)
	{
		m_pstra2userdata->SetOld(m_pstra2userdata->GetNew());
	}		
	else if (3 == m_straindex)
	{
		m_pstra3userdata->SetOld(m_pstra3userdata->GetNew());
	}

	
}

void QtStraUserdata::ClearNew()
{
	if (1 == m_straindex)
	{
		vector<QtStraUserdataCore<userdata_stra1>::QtStraData> tmp;

		//set empty
		m_pstra1userdata->SetNew(tmp);
	}	
	else if (2 == m_straindex)
	{
		vector<QtStraUserdataCore<userdata_stra2>::QtStraData> tmp;

		//set empty
		m_pstra2userdata->SetNew(tmp);
	}		
	else if (3 == m_straindex)
	{
		vector<QtStraUserdataCore<userdata_stra3>::QtStraData> tmp;

		//set empty
		m_pstra3userdata->SetNew(tmp);
	}
}





bool QtStraUserdata::AddInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata)
{
	if (1 == m_straindex)
	{
		return m_pstra1userdata->AddInst(timertype, vpmfcdata);
	}	
	else if (2 == m_straindex)
	{
		return m_pstra2userdata->AddInst(timertype, vpmfcdata);
	}		
	else if (3 == m_straindex)
	{
		return m_pstra3userdata->AddInst(timertype, vpmfcdata);
	}
}



bool QtStraUserdata::DelInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata)
{
	if (1 == m_straindex)
	{
		return m_pstra1userdata->DelInst(timertype, vpmfcdata);
	}	
	else if (2 == m_straindex)
	{
		return m_pstra2userdata->DelInst(timertype, vpmfcdata);
	}		
	else if (3 == m_straindex)
	{
		return m_pstra3userdata->DelInst(timertype, vpmfcdata);
	}
}

bool QtStraUserdata::EditInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata)
{
	if (1 == m_straindex)
	{
		return m_pstra1userdata->EditInst(timertype, vpmfcdata);
	}	
	else if (2 == m_straindex)
	{
		return m_pstra2userdata->EditInst(timertype, vpmfcdata);
	}		
	else if (3 == m_straindex)
	{
		return m_pstra3userdata->EditInst(timertype, vpmfcdata);
	}
}